function bestMoney(arr = []) {
    let min = arr[0];
    let money = 0;
    let i = 1;
    while (i < arr.length) {
        // min = Math.min(min, arr[i]);
        // max = Math.max(max, arr[i+1]);7 3 5 2 20
        if (min > arr[i]) {
            min = arr[i];
        }
        if (arr[i] - min > money) {
            money = arr[i] - min;
        }
        i++;
    }
    console.log(money);
    return money;
}

bestMoney([7,1,5,3,6,4])